package com.ruoyi.whzj.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.whzj.domain.WhTaskcomplaint;
import com.ruoyi.whzj.service.IWhTaskcomplaintService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 任务投诉Controller
 * 
 * @author ruoyi
 * @date 2020-12-30
 */
@Controller
@RequestMapping("/whzj/taskcomplaint")
public class WhTaskcomplaintController extends BaseController
{
    private String prefix = "whzj/taskcomplaint";

    @Autowired
    private IWhTaskcomplaintService whTaskcomplaintService;

    @RequiresPermissions("whzj:taskcomplaint:view")
    @GetMapping()
    public String taskcomplaint()
    {
        return prefix + "/taskcomplaint";
    }

    /**
     * 查询任务投诉列表
     */
    @RequiresPermissions("whzj:taskcomplaint:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(WhTaskcomplaint whTaskcomplaint)
    {
        startPage();
        List<WhTaskcomplaint> list = whTaskcomplaintService.selectWhTaskcomplaintList(whTaskcomplaint);
        return getDataTable(list);
    }

    /**
     * 导出任务投诉列表
     */
    @RequiresPermissions("whzj:taskcomplaint:export")
    @Log(title = "任务投诉", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(WhTaskcomplaint whTaskcomplaint)
    {
        List<WhTaskcomplaint> list = whTaskcomplaintService.selectWhTaskcomplaintList(whTaskcomplaint);
        ExcelUtil<WhTaskcomplaint> util = new ExcelUtil<WhTaskcomplaint>(WhTaskcomplaint.class);
        return util.exportExcel(list, "taskcomplaint");
    }

    /**
     * 新增任务投诉
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存任务投诉
     */
    @RequiresPermissions("whzj:taskcomplaint:add")
    @Log(title = "任务投诉", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(WhTaskcomplaint whTaskcomplaint)
    {
        return toAjax(whTaskcomplaintService.insertWhTaskcomplaint(whTaskcomplaint));
    }

    /**
     * 修改任务投诉
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        WhTaskcomplaint whTaskcomplaint = whTaskcomplaintService.selectWhTaskcomplaintById(id);
        mmap.put("whTaskcomplaint", whTaskcomplaint);
        return prefix + "/edit";
    }

    /**
     * 修改保存任务投诉
     */
    @RequiresPermissions("whzj:taskcomplaint:edit")
    @Log(title = "任务投诉", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(WhTaskcomplaint whTaskcomplaint)
    {
        return toAjax(whTaskcomplaintService.updateWhTaskcomplaint(whTaskcomplaint));
    }

    /**
     * 删除任务投诉
     */
    @RequiresPermissions("whzj:taskcomplaint:remove")
    @Log(title = "任务投诉", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(whTaskcomplaintService.deleteWhTaskcomplaintByIds(ids));
    }

    /**
     * 增减余额
     */
    @GetMapping("/dealComplaint/{id}")
    public String dealComplaint(@PathVariable("id") String id, ModelMap mmap)
    {
        WhTaskcomplaint whTaskcomplaint = whTaskcomplaintService.selectWhTaskcomplaintById(id);
        mmap.put("whTaskcomplaint", whTaskcomplaint);
        return prefix + "/dealComplaint";
    }
}
